package org.stormphoenix.bbsfamily.dao

import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Param
import org.apache.ibatis.annotations.Select
import org.springframework.stereotype.Component
import org.stormphoenix.bbsfamily.entity.AuthorityDO

@Mapper
@Component
interface AuthorityMapper {
    @Select("SELECT * FROM authority WHERE id = #{id}")
    fun findAuthorityById(@Param(value = "id") id: Long): AuthorityDO?

    @Select("SELECT * FROM authority WHERE id IN (SELECT authority_id FROM role_authority WHERE role_id = #{roleId})")
    fun findAuthoritiesByRoleId(@Param(value = "roleId") roleId: Long): List<AuthorityDO>?
}